package com.zues.daiommiddleware.config;

import com.alibaba.nls.client.AccessToken;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
@ConfigurationProperties(prefix = "aliyun.speech")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AliyunVideoProperties {

    private String appKey;

    private String accessKeyId;

    private String accessKeySecret;

    public String getAccessToken() {
        AccessToken accessToken = new AccessToken(accessKeyId, accessKeySecret);
        try {
            accessToken.apply();
            return accessToken.getToken();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
